<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Basic VarnishLog usage</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="varnish.example.stat.html">Basic VarnishStat usage</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="class.varnishadmin.html">VarnishAdmin</a></div>
 <div class="up"><a href="varnish.examples.html">范例</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="varnish.example.log" class="section">
  <h2 class="title">Basic VarnishLog usage</h2>
  <p class="para">
   The example illustrates reading varnish log lines from shared memory
  </p>
  <div class="example" id="example-4578">
   <p><strong>Example #1 Read varnish shared memory log</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$vl&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">VarnishLog</span><span style="color: #007700">;<br />while(</span><span style="color: #0000BB">1</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$line&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$vl</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getLine</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"%s&nbsp;%d&nbsp;%s"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">VarnishLog</span><span style="color: #007700">::</span><span style="color: #0000BB">getTagName</span><span style="color: #007700">(</span><span style="color: #0000BB">$line</span><span style="color: #007700">[</span><span style="color: #DD0000">'tag'</span><span style="color: #007700">],&nbsp;</span><span style="color: #0000BB">$line</span><span style="color: #007700">[</span><span style="color: #DD0000">'id'</span><span style="color: #007700">],<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$line</span><span style="color: #007700">[</span><span style="color: #DD0000">'data'</span><span style="color: #007700">]);<br />}<br /><br />exit(</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
 </div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="varnish.example.stat.html">Basic VarnishStat usage</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="class.varnishadmin.html">VarnishAdmin</a></div>
 <div class="up"><a href="varnish.examples.html">范例</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
